package leetcode.greedy;

/**
 * @author mazouri
 * @create 2021-09-21 10:21
 */
public class _45_jump {
    public int jump(int[] nums) {
        int start = 0;
        int end = 1;
        int count = 0;

        while (end < nums.length) {
            int max = 0;
            for (int i = start; i < end; i++) {
                max = Math.max(max, i + nums[i]);
            }

            start = end;
            end = max + 1;
            count++;
        }
        return count;
    }
}
